package com.bruce.spring.http.api;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.service.annotation.DeleteExchange;
import org.springframework.web.service.annotation.GetExchange;
import org.springframework.web.service.annotation.HttpExchange;
import org.springframework.web.service.annotation.PostExchange;

import java.util.List;
import java.util.Map;

/**
 * Created by bruce in 2025/6/17 02:05
 */
@HttpExchange("/service")
public interface StoreClient {

    @HttpExchange(method = "GET", value = "/stores")
    List<Store> getStores0();

    // GET 请求
    @GetExchange("/getStores1")
    Page<Store> getStores1(Pageable pageable);

    // POST application/json请求
    // 如果方法参数不使用@RequestBody, SpringMVC不会从body中读取数据
    @PostExchange(value = "/postJsonStores")
    Page<Store> postJsonStores(@RequestBody Store store);

    // POST 表单请求,
    @PostExchange(value = "/postFromStores")
    Page<Store> postFormStores(Store store);


    @PostExchange(value = "/requestMap")
    Store requestMap(@RequestParam Map<String, String> params);

    @PostExchange(value = "/requestMapBody")
    Map<String, String> requestMapBody(@RequestBody Map<String, String> params);

    // 返回 ResponseEntity<Store>
    @PostExchange(value = "/responseEntity")
    ResponseEntity<Store> responseEntity(@RequestParam Map<String, String> params);


    @PostExchange(value = "/stores/{storeId}")
    Store usePathVars(@PathVariable("storeId") Long storeId, @RequestBody Store store);


    @DeleteExchange("/stores/{storeId:\\d+}")
    void delete(@PathVariable Long storeId);


}
